<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/jq.autocomplete.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.autocomplete.js"></script>
<script type="text/javascript">
$(function(){
	$("form").submit(function(){
		var product_data = encodeURIComponent($("#prodcut_data").val());
		var warehouse_id = $("#warehouse").val();
		var submit = true;
		if (! product_data)
		{
			alert("请填写出库产品数据!");
			return false;
		}
		$.ajax({
			type:"get",
			url:"<?=url('Storage::OtherIO/CheckAvailableQuantity')?>&product_data="+product_data+"&warehouse_id="+warehouse_id,
			dataType:"json",
			async:false,
			success:
				function(data)
				{
					if (data != '')
					{
						var _html = '';
						$.each(data,function(index, product){
							_html +='<p><span class=\'red\'>' + index + '：' + product + '</span></p>';
						});
						$("#wrong_product").html(_html);
						submit = false;
					}
				}
		});
		return submit;
	});
})
</script>
<form method="post" action="<?=url('Storage::OtherIO/OutCreateSave')?>">
<table class="form_table">
<tr>
	<th>经手人员</th>
	<td>
		<select name="user_id">
			<?foreach ($user as $u):?>
			<option value="<?=$u['id']?>" <?if($u['id']==CURRENT_USER_ID)echo "selected='selected'"?>><?=$u['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>选择仓库</th>
	<td>
		<select name="warehouse_id" id="warehouse">
			<?foreach ($warehouse as $w):?>
			<option value="<?=$w['id']?>"><?=$w['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>备注</th>
	<td colspan="3"><textarea name="notes" cols="40" rows="4"></textarea></td>
</tr>
<tr>
	<td colspan="4">说明：产品编号和数量用逗号（半角英文逗号） 为一条记录，每条记录用回车分开</td>
</tr>
<tr>
	<th>产品</th>
	<td colspan="3"><textarea cols="40" rows="20" name="product_data" id="prodcut_data"></textarea></td>
	<td id="wrong_product"></td>
</tr>
<tr>
	<td><input type="hidden" name="<?=Q::ini('unique_token_name');?>" value="<?=Helper_BSS_Normal::genToken();?>"/></td>
	<td colspan="3"><input type="submit" id="submit" class="button" value="添加出库单" /><span class="red">*注意调拨产品所在的仓库*</span></td>
</tr>
</table>
</form>
<?php $this->_endblock();?>